package org.jeecg.modules.middleware.rabbitmq.config;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
public class RabbitMqConfig {
    //    @Bean(name = "payQueue")
//    public Queue customerQueue() {
//        return new Queue("payQueue", true, false, false);
//    }
//
//    @Bean(name = "payExchange")
//    public DirectExchange customeExchange() {
//        return new DirectExchange("payExchange",true,false);
//    }
//
//
//    @Bean
//    public Binding customerBinding(
//            @Qualifier("payExchange") DirectExchange customeExchange,
//            @Qualifier("payQueue") Queue customerQueue) {
//        return BindingBuilder.bind(customerQueue).to(customeExchange).with("pay");
//    }

    @Bean
    @Scope("prototype")
//    @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE,proxyMode = ScopedProxyMode.TARGET_CLASS)
    public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
        RabbitTemplate template = new RabbitTemplate(connectionFactory);
        return template;
    }
}
